package com.vhuomai.product.mapper;

import com.vhuomai.mybatis.mapper.auto.AutoMapper;
import com.vhuomai.product.entity.BaseProductCategory;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author harris
 */
@Mapper
public interface ProductCategoryMapper extends AutoMapper<BaseProductCategory, Integer> {

    List<BaseProductCategory> findByParentId(@Param("parentId") int parentId);

    @Select("select count(1) from base_product_category where parent_id=#{id}")
    int findChildrenCount(@Param("id") int id);

    BaseProductCategory findByNameParentId(@Param("name") String name);
}
